<template>
  <t-modal
    :title="subtitle"
    width="1408px"
    :visible="visible"
    @cancel="closeModal()"
    wrapClassName="add-modal-container"
    forceRender
    v-bind="footer"
  >
    <div class="curve-modal-body">
      <div class="card">
        <a-empty v-if="imageList.length == 0" />
        <div
          class="image-container"
          v-for="(item, index) in imageList"
          :key="index"
          :class="[filterClass(imageList)]"
        >
          <ViewerImg :toolbar="false">
            <img :src="item.url" />
          </ViewerImg>
        </div>
      </div>
    </div>
  </t-modal>
</template>

<script>
import ViewerImg from "@/components/TopVUI/custom/ViewerImg";
export default {
  components: { ViewerImg },
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    imageList: {
      type: Array,
      default: () => {
        return [];
      },
    },
    subtitle: {
      type: [String, Number],
      default: "查看",
    },
  },

  data() {
    return {
      footer: { footer: null },
    };
  },
  watch: {
    visible: {
      handler(val) {
        if (val) {
        }
      },
      immediate: true,
    },
  },
  methods: {
    //关闭弹窗
    closeModal() {
      this.$emit("update:visible", false);
    },
    filterClass(list) {
      if (list.length == 1) {
        return "one";
      }
    },
  },
};
</script>

<style lang="less" scoped>
/deep/.add-modal-container {
  .ant-modal-body {
    padding: 0 !important;
  }
  .curve-modal-body {
    padding: 24px 16px 24px 32px;
    box-sizing: border-box;
    height: 584px;
    overflow: hidden;
    display: flex;
    .card {
      flex: 1;
      display: flex;
      flex-wrap: wrap;
      overflow-y: auto;
      position: relative;
      .image-container {
        width: 300px;
        height: 224px;
        border-radius: 4px 4px 4px 4px;
        border: 1px solid #d9d9d9;
        margin-right: 16px;
        margin-bottom: 16px;
        position: relative;
        div {
          height: 100%;
          width: 100%;
        }
        img {
          height: 100%;
          width: 100%;
          object-fit: contain;
        }
        &.one {
          width: 100% !important;
          height: 100% !important;
          margin: 0;
        }
      }
      .ant-empty {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
      }
    }
  }
}
</style>
